package com.sunshine.wrongquestionset.room.dao

import androidx.lifecycle.LiveData
import androidx.room.*
import com.sunshine.wrongquestionset.room.entity.UserEntity

/**
 * @author sunshine
 * @date 2021/3/26
 */
@Dao
interface UserDao {
    @Insert(entity = UserEntity::class)
    fun insert(userEntity: UserEntity)

    @Delete(entity = UserEntity::class)
    fun delete(userEntity: UserEntity)

    @Query("SELECT * FROM user WHERE id=:id")
    fun select(id: String): LiveData<UserEntity?>

    @Query("SELECT COUNT(*) FROM user WHERE id=:id")
    fun selectUser(id: String): Int

    @Update(entity = UserEntity::class)
    fun update(userEntity: UserEntity)
}